#ifndef _BMPFORMAT_H_
#define _BMPFORMAT_H_

#include <stdint.h>
#include <nds/ndstypes.h>

typedef struct
{
	char signature[2];
	unsigned int fileSize;
	unsigned int reserved;
	unsigned int offset;
}__attribute__ ((packed)) BmpHeader;
 
typedef struct
{
	unsigned int headerSize;
	unsigned int width;
	unsigned int height;
	unsigned short planeCount;
	unsigned short bitDepth;
	unsigned int compression;
	unsigned int compressedImageSize;
	unsigned int horizontalResolution;
	unsigned int verticalResolution;
	unsigned int numColors;
	unsigned int importantColors;
	
}__attribute__ ((packed)) BmpImageInfo;
 
typedef struct
{
	unsigned char blue;
	unsigned char green;
	unsigned char red;
	unsigned char reserved;
}__attribute__ ((packed)) Rgb;
 
typedef struct
{
	BmpHeader header;
	BmpImageInfo info;
	Rgb palette[1];
}__attribute__ ((packed)) BmpFile;


void print_BmpInfo(BmpFile *bmp);

unsigned char validateBmp(BmpFile *bmp);

void displayBmp(BmpFile *bmp, u16 *video_buffer);

void uploadPalette(BmpFile *bmp, u16 *screen_palette);
void displayIndexedBmp(BmpFile *bmp, u16 *video_buffer);

void displayTestPattern(u16 *video_buffer, uint8_t palette_offset, uint8_t colors);

#endif //_BMPFORMAT_H_
